#!/bin/bash
source experiment.cfg

# start controller
controller_dns=$(cat $controller_dns_file)
ssh -i $key_file -o StrictHostKeyChecking=no ec2-user@$controller_dns "~/run-java.sh controller $controller_dns 10000 $controller_dns $fanout $experiment $leaf_count 0" & 
echo "Started controller on $controller_dns"

# start nodes
i=0;
cat $node_dns_file | while read line; 
do
    i=`expr $i + 1`;
    ssh -i $key_file -o StrictHostKeyChecking=no ec2-user@${line} "~/run-java.sh leaf ${line} 10000 $controller_dns $fanout $experiment $leaf_count ${i}" & 
    echo "Started node on ${line}"; 
done
